t = input()
stack = []
og = ['(', '[', '{', '<']
cg = [')', ']', '}', '>']

for c in s:
    if c in og:
        stack.append(c)
    elif c in cg:
        if not stack or cg[og.index(stack.pop())] != c:
            print(False)
            break
else:
    print(not stack)
